package com.zhao.dota.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhao.dota.model.Quotation;
import com.zhao.dota.vo.QuotationVo;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface QuotationMapper extends BaseMapper<Quotation> {

    @Select("select q.*,u.nick_name as userName, u.avatar as userAvatar," +
            "       t.nick_name as targetName, t.avatar as targetAvatar from quotation q " +
            "  left join user u " +
            "    on q.user_id = u.id " +
            "  left join user t " +
            "    on q.target = t.id " +
            " where q.round_id = #{roundId}")
    List<QuotationVo> findByRoundId(Integer roundId);

    @Select("select max(gold) from quotation where round_id = #{roundId} and hero_id = #{heroId}")
    Integer findMaxGoldByRoundIdHeroId(Integer roundId, Integer heroId);

}
